<?php
class Cabang_model extends Model{

/**
*Constructor
*/
function Cabang_model()
{
parent::Model();
}

//inisiasi nama tabel yang digunakan*/
var $table = 'cabang';

//mendapatkan semua data cabang berdasarkan id_cabang*/

function get_cabang()
{
	$this->db->order_by('id_cabang');
	return $this->db->get('cabang');
}



//mendapatkan semua data cabang berdasarkan id_cabang*/

function get_cabang2($id_cabang)
{
	$this->db->where('id_cabang',$id_cabang);
	return $this->db->get('cabang');
}

//mendapatkan data sebuah cabang*/
function get_cabang_by_id($id_cabang)
{
	return $this->db->get_where($this->table, array('id_cabang' => $id_cabang), 1)->row();
}


function get_all()
	{
		$this->db->order_by('id_cabang');
		return $this->db->get($this->table);
}

//mengapus data cabang*/
function delete($id_cabang)
{
	$this->db->delete($this->table, array('id_cabang' => $id_cabang));
}

//tambah cabang*/
function add($cabang)
{
	$this->db->insert($this->table, $cabang);
	
}

function update($id_cabang, $cabang)
{
 $this->db->where('id_cabang', $id_cabang);
 $this->db->update($this->table, $cabang);
}
//validasi id cabang agar tidak ganda*/
function valid_id($id_cabang)
{
	$query = $this->db->get_where($this->table, array('id_cabang' => $id_cabang));
	if ($query->num_rows() > 0)
	{
	return TRUE;
	}
	else
	{
	return FALSE;
	}
	}
}

// END Cabang_model Class

/* End of file cabang_model.php */
/* Location: ./system/application/models/cabang_model.php */	